<?php

namespace IDock\Insurance\ZSIC\Request;

use IDock\Insurance\ZSIC\Request\AllZSICRequest;
use IDock\Insurance\ZSIC\Response\ElecPolicyDownloadResponse;
use IDock\Insurance\ZSIC\Response\UploadFileResponse;
use IDock\Insurance\ZSIC\Response\VehicleModelResponse;
use IDock\Visitor\EPolicyDownloadVisitor;
use IDock\Visitor\UploadFileVisitor;
use IDock\Visitor\VehicleModelVisitor;

/**
 * 电子保单下载
 */
class ElecPolicyDownloadRequest extends AllZSICRequest
{
    protected $response = ElecPolicyDownloadResponse::class;

    protected $urlTip = '电子保单下载';

    public $requestCode = 'getEle';

    /**
     * @var EPolicyDownloadVisitor $visitor
     */
    protected $visitor;

    public function generate(): array
    {
        $arr = [
            'application' => '',
            'formType' => 'PDF',
            'reqType' => '02',
            'cSlsCde' => '123123',
        ];
        if(!empty($this->visitor->biPolicyNo)){
            $arr['application'] = [
                'plyAppNo' => $this->visitor->biPolicyNo,
                'prodNo' => 'GAUTO',
                'certfCde' => $this->visitor->argc['applyLicenseNo'] ?? '',
            ];
        }
        if(!empty($this->visitor->ciPolicyNo)){
            $arr['application'] = [
                'plyAppNo' => $this->visitor->ciPolicyNo,
                'prodNo' => 'MAUTO',
                'certfCde' => $this->visitor->argc['applyLicenseNo'] ?? '',
            ];
        }
        if(isset($this->visitor->argc['nonCarPolicyNo'])){
            $arr['application'] = [
                'plyAppNo' => $this->visitor->argc['nonCarPolicyNo'] ?: '',
                'prodNo' => '0622',
                'certfCde' => $this->visitor->argc['applyLicenseNo'] ?? '',
            ];
        }
        return $arr;
    }

    public function getBusinessNo()
    {
        return $this->visitor->argc['businessNo'] ?? '';
    }
}
